<template>
	<view class="cardlist">
		<template v-if="cartlists.length">

			<view class="card" v-for="(item, index) in cartlists" :key="index">
				<view class="del" @click="delCard(item.id)">删除</view>
				<view class="">{{ item.cardaddress }}</view>
				<view class="" style="color: #626c7a;font-size: 24rpx ;margin: 12rpx 0;">储蓄卡</view>
				<view class="">{{ item.cardno2 }}</view>
			</view>
		</template>
		<template v-else>
			<u-empty text="暂无银行卡数据" mode="data"></u-empty>
		</template>
		<view class="addcard" @click="goPath('/pages/user/addcard/addcard')">添加银行卡</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				cartlists: []
			};
		},
		onShow() {
			this.getCard();
		},
		methods: {
			onPullDownRefresh() {
				setTimeout(function() {
					uni.stopPullDownRefresh();
				}, 1000);
			},
			async getCard() {
				this.https('/order/masterBankList', {}).then(res => {
					this.cartlists = res.data.list;
				});
			},
			async delCard(id) {
				uni.showLoading();
				this.https('/order/delMasterBank', { bank_id: id }).then(res => {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					});
					this.getCard();
					uni.hideLoading();
				});
			}
		}
	};
</script>

<style lang="scss">
	page {
		background-color: #f5f5f5;
	}

	.cardlist {
		padding: 32rpx;
	}

	.addcard {
		position: absolute;
		bottom: 32rpx;
		border-radius: 16rpx;
		left: 2%;
		width: 96%;
		text-align: center;
		height: 100rpx;
		line-height: 100rpx;
		color: #fff;
		background-color: #45bb52;
	}

	.card {
		position: relative;
		// width: 100%;
		border-radius: 16rpx;
		background-color: #fff;
		padding: 32rpx;
		margin-bottom: 32rpx;
	}

	.del {
		position: absolute;
		right: 32rpx;
		top: 32rpx;
		font-size: 24rpx;
		color: #45bb52;
	}
</style>